package com.itany.springcloud.springcloudnacosopenfeignconsumer.service;

import com.itany.springcloud.springcloudcommon.entity.User;
import com.itany.springcloud.springcloudcommon.vo.ResponseResult;
import com.itany.springcloud.springcloudnacosopenfeignconsumer.fallback.UserServiceFallbackFactory;
import com.itany.springcloud.springcloudnacosopenfeignconsumer.service.fallback.UserServiceFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

@Service
//@FeignClient(value = "springcloud-nacos-provider",fallback = UserServiceFallback.class)
//@FeignClient(value = "springcloud-nacos-gateway",fallback = UserServiceFallback.class,contextId = "service1")

//@FeignClient(value = "springcloud-nacos-gateway")
@FeignClient(value = "springcloud-nacos-gateway",fallbackFactory = UserServiceFallbackFactory.class,contextId = "service1")

public interface UserService {


    @GetMapping("/ums/user")
    public ResponseResult findAll();

    @GetMapping("/ums/user/{id}")
    public ResponseResult findById(@PathVariable("id") Integer id);

    @PostMapping("/ums/user")
    public ResponseResult add(@RequestParam("username") String username,
                              @RequestParam("password") String password);

    @PostMapping("/ums/user/add2")
    public ResponseResult add2(@RequestBody User user);

    //SpringCloud 2.1以后使用
    @PostMapping("/user/add3")
    public ResponseResult add3(@SpringQueryMap User user);

    @DeleteMapping("/ums/user/{id}")
    public ResponseResult remove(@PathVariable("id") Integer id);

    @PutMapping("/ums/user")
    public ResponseResult modify(@RequestParam("id") Integer id,
                                 @RequestParam("username") String username,
                                 @RequestParam("password") String password);


//    @GetMapping("/user")
//    public ResponseResult findAll();
//
//    @GetMapping("/user/{id}")
//    public ResponseResult findById(@PathVariable("id") Integer id);
//
//    @PostMapping("/user")
//    public ResponseResult add(@RequestParam("username") String username,
//                              @RequestParam("password") String password);
//
//    @PostMapping("/user/add2")
//    public ResponseResult add2(@RequestBody User user);
//
//    //SpringCloud 2.1以后使用
//    @PostMapping("/user/add3")
//    public ResponseResult add3(@SpringQueryMap User user);
//
//    @DeleteMapping("/user/{id}")
//    public ResponseResult remove(@PathVariable("id") Integer id);
//
//    @PutMapping("/user")
//    public ResponseResult modify(@RequestParam("id") Integer id,
//                                 @RequestParam("username") String username,
//                                 @RequestParam("password") String password);


}
